#!/usr/bin/env python
import sys

class HelpJson(object):
    @staticmethod
    def loads(line):
        obj = None
        try:
            obj = eval(line)
        except:
            sys.stderr.write('Some format error at %s\n' %(line))
        return obj

class Helper(object):
    
    def loader(self, line):
        line = line.strip()
        [left, right] = line.split('\t')
        return (left, right)

    def allocator(self, key, value):
        print '%s\t%s' % (key, value)

    def processor(self, key, lst):
        print 'haha'

    def join(self, left, right, sep=','):
        return sep.join([str(left), str(right)])

    def split(self, line, sep=','):
        if line.find(sep) != -1:
            return (line.split(',')[0], line.split(',')[1])
        else:
            return (None, None)


class ReducerHelper(Helper):

    def reducer(self):
        key = ''
        collector = []
        for line in sys.stdin:
            left, right = self.loader(line)
            if left == key:
                collector.append(right)
            else:
                if key != '':
                    self.processor(key, collector)
                key = left
                collector = []
                collector.append(right)
        if key != '':
            self.processor(key, collector)

class MapperHelper(Helper):

    def mapper(self):
        pass
